<?php
/**
* CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10
* GNU General Public License
* Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
* elpidio@care2x.org, 
*
* See the file "copy_notice.txt" for the licence notice
*/

error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
require('./roots.php');
require($root_path.'include/inc_environment_global.php');

/*el archivo de lenguaje esta en su carpeta correspondiente de idioma y se llama lang_es_interconsulta.php (es en nuestro caso claro...*/
define('LANG_FILE','interconsulta.php');
define('NO_2LEVEL_CHK',1);
require_once($root_path.'include/inc_front_chain_lang.php');
// reset all 2nd level lock cookies
require($root_path.'include/inc_2level_reset.php');

global $db;
$thisfile=basename(__FILE__);
$breakfile=$root_path.'interconsulta/interconsulta.php'.URL_APPEND."&lang=$lang&msj=$msj";
$action='interconsulta-espeusuario-save.php'.URL_APPEND."&lang=$lang&msj=$msj";
$_SESSION['sess_path_referer']=$top_dir.$thisfile;

# Start Smarty templating here
/**
* LOAD Smarty
*/

# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme

?>
                <script  language="javascript">
				function popSearchWin(target,obj_val,obj_name){
                        urlholder="./data_search.php<?php echo URL_REDIRECT_APPEND; ?>&target="+target+"&obj_val="+obj_val+"&obj_name="+obj_name;
                        DSWIN<?php echo $sid ?>=window.open(urlholder,"wblabel<?php echo $sid ?>","menubar=no,width=400,height=550,resizable=yes,scrollbars=yes");
                }

        function usuarioBlur()
        { 
            <?php
					
					//Importacion y creacion de instancia de la clase queries_interconsulta_espeusuario
					$filename = $root_path."db/interconsulta/queries_interconsulta_espeusuario.php";
					require_once($filename);

					$query_interconsulta_espeusuario = new Queries_interconsulta_espeusuario();

                    //$sql = "SELECT id, descripcion from care_interconsulta_especialidad";
					$sql = $query_interconsulta_espeusuario->select_care_interconsulta_especialidad();
					
		$i = 0;
                     if($result=$db->Execute($sql)){
                        while($temp=$result->FetchRow())
                        {

			if ($temp["descripcion"]=='Medicina Interna'){
				
				echo 'var option0 = new Option("' . $LDMedicinaInterna . '", "' . $temp['id'] . '");';
                        	echo 'document.regform.noasig.options[' . $i . '] = option0;';

			}elseif ($temp["descripcion"]=='Pediatria'){
				echo 'var option0 = new Option("' . $LDPediatria . '", "' . $temp['id'] . '");';
                        	echo 'document.regform.noasig.options[' . $i . '] = option0;';

			}elseif ($temp["descripcion"]=='Gineco-obstetra'){
				echo 'var option0 = new Option("' . $LDGinecoObstetra . '", "' . $temp['id'] . '");';
                        	echo 'document.regform.noasig.options[' . $i . '] = option0;';

			}elseif ($temp["descripcion"]=='Cirugia'){
				echo 'var option0 = new Option("' . $LDCirugia . '", "' . $temp['id'] . '");';
                        	echo 'document.regform.noasig.options[' . $i . '] = option0;';

			}elseif ($temp["descripcion"]=='Cardiologia'){
				echo 'var option0 = new Option("' . $LDCardiologia . '", "' . $temp['id'] . '");';
                        	echo 'document.regform.noasig.options[' . $i . '] = option0;';

			}elseif ($temp["descripcion"]=='Dermatologia'){
				echo 'var option0 = new Option("' . $LDDermatologia . '", "' . $temp['id'] . '");';
                        	echo 'document.regform.noasig.options[' . $i . '] = option0;';

			}else{
				echo 'var option0 = new Option("' . $temp["descripcion"] . '", "' . $temp['id'] . '");';
                        	echo 'document.regform.noasig.options[' . $i . '] = option0;';

			}
                            $i++;
                        }
                    }
                    
            ?>
        }


        function getAsig()
        {
            var sda1 = document.getElementById('asig');
            var len = sda1.length;
            var acum = "";

            for (var j=0;j<len;j++)
            {
                acum += sda1.options[j].value + ":";
            }

            document.getElementById('asigacum').value = acum;

            return true;
        }

        function moveoutid()
        {
                var sda = document.getElementById('noasig');;
                var len = sda.length;
                var sda1 = document.getElementById('asig');
                for(var j=0; j<len; j++)
                {
                        if(sda[j].selected)
                        {
                                var tmp = sda.options[j].text;
                                var tmp1 = sda.options[j].value;
                                sda.remove(j);
                                j--;
                                var y=document.createElement('option');
                                y.text=tmp;
                                y.value=tmp1;
                                try
                                {sda1.add(y,null);
                                }
                                catch(ex)
                                {
                                sda1.add(y);
                                }
                        }
                }
        }


        function moveinid()
        {
                var sda = document.getElementById('noasig');
                var sda1 = document.getElementById('asig');
                var len = sda1.length;
                for(var j=0; j<len; j++)
                {
                        if(sda1[j].selected)
                        {
                                var tmp = sda1.options[j].text;
                                var tmp1 = sda1.options[j].value;
                                sda1.remove(j);
                                j--;
                                var y=document.createElement('option');
                                y.text=tmp;
                                y.value=tmp1;
                                try
                                {
                                sda.add(y,null);}
                                catch(ex){
                                sda.add(y);	
                                }
                        }
                }
        }

        </script>
<?php

require_once($root_path.'gui/smarty_template/smarty_care.class.php');
$smarty = new smarty_care('common');

# Create a helper smarty object without reinitializing the GUI
$smarty2 = new smarty_care('common', FALSE);

# Added for the common header top block

$smarty->assign('sToolbarTitle',$LDInter);
$smarty->assign('breakfile',$breakfile);
$smarty->assign('action',$action);

# Window bar title
$smarty->assign('title',$LDEspeUsuario);

$smarty->assign('LDUsuario',$LDUsers);
$smarty->assign('sUsuarioInput','<input name="login_id" type="text" size="10" onblur="usuarioBlur()">');
$smarty->assign('sUsuarioMiniCalendar',"<a href=\"javascript:popSearchWin('usuario')\"><img ".createComIcon($root_path,'b-write_addr.gif','0')."></a>");

$smarty->assign('LDEspecialidad',$LDEspecialidad);
$smarty->assign('sNoAsigSelect','<select name="noasig[]" id="noasig" multiple size="7" width="10"></select>');
$smarty->assign('sAsigSelect','<select name="asig[]" id="asig" multiple size="7" width="10"></select>');
$smarty->assign('pbAddRem', '<input type="button" value=">>" onclick="moveoutid()"><br><input type="button" value="<<" onclick="moveinid()">');

$smarty->assign('asigacum', '<input type="hidden" value="" name="asigacum" id="asigacum">');

$smarty->assign('pbSubmit','<input type="image" '.createLDImgSrc($root_path,'savedisc.gif','0').'  alt="'.$LDSaveData.'" align="absmiddle">');

$smarty->assign('sMainBlockIncludeFile','interconsulta/espeusuario.tpl');

/**
* show Template
*/

$smarty->display('common/mainframe.tpl');
?>
